<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>{{$goodData['goods_name']}}</title>
		<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
		<link rel="stylesheet" type="text/css" href="Public/Home/css/base.css" />
		<link href="Public/Home/css/detail(1).css" type="text/css" rel="stylesheet"  />
		
		<script type="text/javascript" src="Public/Home/js/jquery-1.9.1.min.js"></script>
		
		<script type="text/javascript" src="Public/Home/js/detail.js"></script>
		<!--放大镜 开始-->
		<link href="Public/Home/css/loupe.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="Public/Home/js/jquery.jqzoom.js"></script>
		<script type="text/javascript" src="Public/Home/js/loupe.js"></script>
		<!--放大镜 结束-->
		<script>
			$(function(){
			//规格选择
			//鼠标滑过规格 并 点击选择规格
			$('.prdmod a').hover(function(){
				$(this).addClass('hover');
			},function(){
				$(this).removeClass('hover');
			})
			
			$('.prdmod a').click(function(){
				
				$(this).addClass('select').parent('.prdmod').siblings('.prdmod').children('a').removeClass('select');
				var sprice = $('.price span').html();
				//alert(sprice);
				var newprice = $(this).attr('price');
				//alert(newprice);
				
				var str = "<em>¥</em>"+newprice;
				//商城价
				$('.price').html(str);
				//市场价
				$('.gprice').val(newprice);
				
				var spec =document.getElementsByClassName("select");
				//alert(spec.length);
				
				if(spec.length == 2){
					var res = ''; 
					for(var i=0;i<spec.length;i++){
						res = spec[0].getAttribute("ga_id");
					    res += ','+ spec[i].getAttribute("ga_id");
					}								
					res = res;

					//发送异步
					$.ajax({
						type:"post",
						url:"{{U('Cart/ajaxStock')}}",
						data:{res:res},
						dataType:'json',
						success:function(phpData){//请求之后，响应成功执行
							//请求返回来的json数据
							//{"cargo_id":"5","cargo_number":"234","cargo_sn":"16012611519487","spec":"57,60","goods_goods_id":"15"}
							
							if(phpData){
								$('.remain span').html(phpData.cargo_number);
								$('.prdbuycnt,.prdcart').show();
								$("#txtChoose").hide();
							}else{
								//$('.remain span').html(0);
								$('.prdbuycnt,.prdcart').hide();
								$("#txtChoose").show();
								$("#txtChoose").html("商品库存为0,请重新选择！！");
							}
							
															
						}
					});
				}
				
			})
			 $('.j-gACbtnA').click(function(){
				  var num = $('.j-gACval').val();
				  if(num < 99999 && num >= 0){
					  var newNum = parseInt(num) + parseInt(1);
					  $('.j-gACval').attr('value',newNum);
					  var str = newNum;
					  $('.chooseNum').html(str);
				  }
			  })
			  $('.j-gACbtn').click(function(){
				  var num = $('.j-gACval').val();
				  if(num < 99999 && num > 0){
					  var newNum = parseInt(num) - parseInt(1);
					  $('.j-gACval').attr('value',newNum);
					  var str = newNum;
					  $('.chooseNum').html(str);
				  }
			  })


			  //得到
			  $('.addCart').click(function(){
			  	//alert(1);
			  	//商品颜色分类 和 尺码
			  	var color = '';
			  	var size = '';
			  	var spec =document.getElementsByClassName("select");
			  	for(var i = 0; i < spec.length; i++){
				    size  = spec[0].getAttribute("val");
					color = spec[1].getAttribute("val");	    
				}
					
				//商品ID
				var gid = $('#goods_id').val();
				//商品名称
				var gname = $('#goods_name').val();
				//商品数量
				var gnum = $('.j-gACval').val();
				//商品图
				var gpic = $('.jqzoom img').attr('src');
				//商品市场价
				var mprice = $('#market_price').val();
				//商品商城价
				var sprice = $('#shop_price').val();
				//商品分类id
				var cid = $("#cate_id").val();
				//alert(cid);
				//发送异步
				$.ajax({
					type:"post",
					url:"{{U('Cart/addCart')}}",
					data:{id:gid,name:gname,num:gnum,pic:gpic,mprice:mprice,sprice:sprice,color:color,size:size,cid:cid},
					dataType:'json',
					success:function(Data){//请求之后，响应成功执行页面跳转
						//alert(1);
						location.href="{{U('Cart/index')}}";						
					}
				});	
			  })
			})
		</script>
	</head>
	<body>
		{{include file="VIEW_PATH/Common/header_d.php"}}
		<input type="hidden" name="cate_id" id="cate_id" value="{{$goodData['gcategory_cate_id']}}" />
		<input type="hidden" name="goods_id" id="goods_id" value="{{$goodData['goods_id']}}" />
		<input type="hidden" name="goods_name" id="goods_name" value="{{$goodData['goods_name']}}" />
		<input type="hidden" name="market_price" id="market_price" value="{{$goodData['market_price']}}" />
		<input type="hidden" name="shop_price" id="shop_price" value="{{$goodData['shop_price']}}" />
		<!--当前位置 开始-->
		<div class="wbox">
			<div class="local">
			<a title="首页" href="index.php">首页</a><i class="crumbarrow"> > </i>
			<a  href="{{U('List/index',array('cate_id'=>0))}}">所有分类</a>
            {{if value="isset($currentNav)"}}
            {{foreach from="$currentNav" value="$v"}}
            <i class="crumbarrow"> > </i><a href="{{U('List/index',array('cate_id'=>$v['cate_id']))}}">{{$v['cate_name']}}</a>
            {{endforeach}}
            {{endif}}
            <span class="linkGray">{{$goodData['goods_name']}}</span>
			</div>
		</div>
		<!--当前位置 结束-->
		
		<!--商品规格-->
		<div class="wbox" style="margin-bottom: 2px;">
			<!--放大镜-->
			  <div class="prd-images fl" style="width: 380px;">
			    <div id="preview" class="spec-preview"> 
			        <span class="jqzoom">
			             <img jqimg="{{$goodData['goods_img'][0]}}" src="{{$goodData['goods_img'][0]}}" width="360" height="360" />
			        </span> 
			    </div>
			    <!--缩图开始-->
			    <div class="spec-scroll"> 
			    	  <a class="prev">&lt;</a>
			          <a class="next">&gt;</a>
			          <div class="items">
			            <ul>
						{{foreach from="$goodData['goods_img']" value="$v"}}
						<li><img alt="{{$goodData['goods_name']}}" bimg="{{$v}}" src="{{$v}}" onmousemove="preview(this);"></li>
						{{endforeach}}
			            </ul>
			          </div>
			    </div>
			    <!--缩图结束-->
			  </div>
			<!--放大镜_ok-->
			<!--参数-->
			<ul class="prdmain">
				<li class="prdtit"><h1>{{$goodData['goods_name']}}</h1></li>
				<li class="prdprice">
					<div class="p-price clearfix">
						<span class="price"><em class="fl">¥</em><span>{{$goodData['shop_price']}}</span></span>
						<span class="originalPrice"><i class="fl">¥</i><span>{{$goodData['market_price']}}</span></span>
						<span class="fallPrice">已降{{$goodData['lessen']}}元</span>
						<span class="notice"><a href="javascript:void(0);" id="reduce">降价通知</a></span>
					</div>
				</li>
				<li class="prd_pingjia clearfix">
					<div class="prdLeft">商品评价：</div>
					<div class="prdRight">
			            <div class="fleft">
			            <span class="haopin">好评度</span>
			            <span class="haocnt nocnt" id="haocnt">--</span>
			            <span class="pincnt"><a href="javascript:;" id="goappr"><b id="pincnt">0</b>人评价</a></span>
			            </div>
			        </div>
				</li>
				<!--送至-->
				<li class="prdcity clearfix">
					<div class="prdLeft">送　　至：</div>
					<div class="prdRight">
						<span class="regon">
			            	<a href="javascript:;" title="北京市东城区全部区域">北京市东城区全部区域</a>
			                <i></i>
			            </span>
			            {{if value="$goodData['goods_number'] >=1"}}
			            <span class="prdstock">有货</span>
			            {{else}}
			            <span class="prdstock">无货</span>
			            {{endif}}
					</div>
				</li>
				<!--规格-->
				<input type="hidden" name="goods_id" value="{{$_GET['goods_id']}}"  />		
				{{foreach from="$goodsAttr" key="$k" value="$v"}}	
					<li class="prdother clearfix">
						<div class="prdLeft" k="{{$k}}">选择{{$v['fattr_name']}}：</div>
						<div class="prdRight">
						{{foreach from="$goodsAttr[$k]['spec']" key="$kk" value="$vv"}}															
							<div class="prdmod">
								<a href="javascript:;" price="{{$vv['attr_price']}}" ga_id="{{$vv['ga_id']}}" id="{{$vv['ga_id']}}" val="{{$vv['ga_value']}}">
									{{$vv['ga_value']}}
								</a>
							</div>											
						{{endforeach}}
						</div>
					</li>			
				{{endforeach}}
				<!--数量-->
				<li class="prdbuycnt clearfix">
					<div class="prdLeft">购买数量：</div>
					<div class="prdRight btnCount">
						<!--改变 购买数量-->
			        	<a class="j-gACbtn" href="javascript:;">-</a>
			            <input type="text" class="j-gACval" maxlength="5" id="enterQty" name="Qty" value="1"  >
			            <a class="j-gACbtnA" href="javascript:;">+</a>
			            
			            <div class="remain" style="display: block;">
			            	仅剩<span>{{$goodData['goods_number']}}</span>{{$goodData['unit']}}
			            </div>
			        </div>
				</li>
				<li id="txtChoose" class="prdchoose">
				</li>
				{{if value="$goodData['goods_number'] >=1"}}
				<li class="prdcart clearfix">
					<div class="temp-wrap1">
						<a href="javascript:;" class="addCart">加入购物车</a>
						<a href="javascript:;" id="easyShopping" title="快速购物">快速购</a>
					</div>
				</li>
				{{else}}
				<li class="prdcart clearfix">
					<div class="temp-wrap1">
						<span>无货</span>
						<a href="javascript:;" id="easyShopping" title="快速购物">快速购</a>
					</div>
				</li>
				{{endif}}
			</ul>

			<div class="fr oh" style="width:190px;padding:10px 10px 466px 10px; margin-bottom:-1000px;"></div>

		</div>

		<p style="margin: 30px auto;"></p>
		
		<!--详细信息-->
		<div class="wbox">
			<!--右-->
			<div class="dt-main">
				<div class="prdDescOut">
					<div class="pdtl-tab">
						<ul class="prdtitbox">
							<li class="cur"><a href="javascript:;">商品详情</a></li>
							<li><a href="javascript:;">具体参数</a></li>
							<li><a href="javascript:;" class="pingjia_header">商品评价</a></li>
						</ul>
					</div>
					<!--下-->
					<ul class="pedmainbox">
						<li style="display:block;">
							{{$goodData['goods_desc']}}
						</li>
						<li style="display:none;">具体参数</li>
						<li style="display:none;">商品评价</li>
					</ul>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		<!--详细信息_ok-->
	
    {{include file="VIEW_PATH/Common/footer.php"}}
    
    
    <div class="tsk">商品库存为0，请重新选择</div>
	</body>
</html>
